package com.example.service.serviceImpl;

import com.example.domain.Resource;
import com.example.mapper.ResourceMapper;
import com.example.service.ResourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ResourceServiceImpl implements ResourceService {

    @Autowired
    ResourceMapper resourceMapper;

    @Override
    public Resource selectResourceById(String id) {
        return resourceMapper.selectResourceById(id);
    }

    @Override
    public List<Resource> selectResourceByUid(String id) {
        return resourceMapper.selectResourceByUid(id);
    }

    @Override
    public List<Resource> showAllResource() {
        return resourceMapper.showAllResource();
    }

    @Override
    public List<Resource> showDeleteResource() {
        return resourceMapper.showDeleteResource();
    }

    @Override
    public Integer hasId(String rid) {
        return resourceMapper.hasId(rid);
    }

    @Override
    public Boolean updateUid(String rid, Integer uid) {
        return resourceMapper.updateUid(rid,uid);
    }

    @Override
    public Boolean borrowUpdate(Resource resource) throws Exception {
        return resourceMapper.borrowUpdate(resource);
    }

    @Override
    public Boolean returnUpdate(Resource resource) throws Exception {
        return resourceMapper.returnUpdate(resource);
    }

    @Override
    public Boolean insert(Resource resource) throws Exception {
        return resourceMapper.insert(resource);
    }

    @Override
    public List<Resource> delete(int id) throws Exception {
        resourceMapper.delete(id);
        return resourceMapper.showAllResource();
    }

    @Override
    public List<Resource> selectResourceByAll(String object) throws Exception {
        return resourceMapper.searchResourceByAll(object);
    }

    @Override
    public Integer selectUidById(String id) throws Exception {
        return resourceMapper.selectUidById(id);
    }

    @Override
    public List<String> selectRidByUid(Integer id) throws Exception {
        return resourceMapper.selectRidByUid(id);
    }

}
